import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  { path: '/register', component: () => import('@/views/register/index'), hidden: true },
  { path: '/member', component: () => import('@/views/member/index'), hidden: true },
  { path: '/member/build', component: () => import('@/views/member/build'), hidden: true },
  { path: '/member/park', component: () => import('@/views/member/park'), hidden: true },
  { path: '/member/charge', component: () => import('@/views/member/charge'), hidden: true },
  { path: '/member/temporarypark', component: () => import('@/views/member/temporarypark'), hidden: true },
  { path: '/member/complaint', component: () => import('@/views/member/complaint'), hidden: true },
  { path: '/member/addComplaint', component: () => import('@/views/member/addComplaint'), hidden: true },
  { path: '/member/addTemporarypark', component: () => import('@/views/member/addTemporarypark'), hidden: true },
  
  {
    path: '/',
    component: Layout,
    redirect: '/login',
    name: 'Home',
    hidden: true,
    children: [
      {
          path: '/login',
          component: import('@/views/login/index'),
          name: 'Login'
      },
      {
        path: '/dashboard',
        component: import('@/views/dashboard/index'),
        name: 'Dashboard'
      }
    ]
  },

  {
    path: '/build',
    component: Layout,
    redirect: '/build/table',
    name: '楼栋管理',
    meta: { title: '楼栋管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '楼栋列表',
        component: () => import('@/views/pro/build/list'),
        meta: { title: '楼栋列表'}
      },
      {
        path: 'save',
        name: '添加楼栋',
        component: () => import('@/views/pro/build/save'),
        meta: { title: '添加楼栋'}
      },
      {
        path: 'update/:id',
        name: 'ProBuildEdit',
        component: () => import('@/views/pro/build/save'),
        meta: { title: '修改楼栋', noCache: true },
        hidden: true
      }
    ]
  },

  {
    path: '/house',
    component: Layout,
    redirect: '/house/table',
    name: '房屋管理',
    meta: { title: '房屋管理', icon: 'table' },
    children: [
      {
        path: 'table',
        name: '房屋列表',
        component: () => import('@/views/pro/house/list'),
        meta: { title: '房屋列表' }
      },
      {
        path: 'save',
        name: '添加房屋',
        component: () => import('@/views/pro/house/save'),
        meta: { title: '添加房屋'}
      },
      {
        path: 'update/:id',
        name: 'ProHouseEdit',
        component: () => import('@/views/pro/house/save'),
        meta: { title: '修改房屋', noCache: true },
        hidden: true
      }
    ]
  },

  {
    path: '/owner',
    component: Layout,
    redirect: '/owner/table',
    name: '业主管理',
    meta: { title: '业主管理', icon: 'tree' },
    children: [
      {
        path: 'table',
        name: '业主列表',
        component: () => import('@/views/pro/owner/list'),
        meta: { title: '业主列表'}
      },
      {
        path: 'save',
        name: '添加业主',
        component: () => import('@/views/pro/owner/save'),
        meta: { title: '添加业主'}
      },
      {
        path: 'update/:id',
        name: 'ProOwnerEdit',
        component: () => import('@/views/pro/owner/save'),
        meta: { title: '修改业主', noCache: true },
        hidden: true
      }
    ]
  },

  {
    path: '/charge',
    component: Layout,
    redirect: '/charge/table',
    name: '收费管理',
    meta: { title: '收费管理', icon: 'nested' },
    children: [
      {
        path: 'table',
        name: '收费列表',
        component: () => import('@/views/pro/charge/list'),
        meta: { title: '收费列表'}
      },
      {
        path: 'save',
        name: '添加收费',
        component: () => import('@/views/pro/charge/save'),
        meta: { title: '添加收费'}
      },
      {
        path: 'update/:id',
        name: 'ProChargeEdit',
        component: () => import('@/views/pro/charge/save'),
        meta: { title: '修改收费', noCache: true },
        hidden: true
      }
    ]
  },

  {
    path: '/complaint',
    component: Layout,
    redirect: '/complaint/table',
    name: '投诉管理',
    meta: { title: '投诉管理', icon: 'form' },
    children: [
      {
        path: 'table',
        name: '投诉列表',
        component: () => import('@/views/pro/complaint/list'),
        meta: { title: '投诉列表'}
      },
      {
        path: 'save',
        name: '添加投诉',
        component: () => import('@/views/pro/complaint/save'),
        meta: { title: '添加投诉'}
      },
      {
        path: 'update/:id',
        name: 'ProComplaintEdit',
        component: () => import('@/views/pro/complaint/save'),
        meta: { title: '修改投诉', noCache: true },
        hidden: true
      }
    ]
  },

  {
    path: '/park',
    component: Layout,
    redirect: '/park/table',
    name: '停车管理',
    meta: { title: '停车管理', icon: 'table' },
    children: [
      {
        path: 'table',
        name: '停车列表',
        component: () => import('@/views/pro/park/list'),
        meta: { title: '停车列表' }
      },
      {
        path: 'save',
        name: '添加停车',
        component: () => import('@/views/pro/park/save'),
        meta: { title: '添加停车'}
      },
      {
        path: 'update/:id',
        name: 'ProParkEdit',
        component: () => import('@/views/pro/park/save'),
        meta: { title: '修改停车', noCache: true },
        hidden: true
      }
    ]
  },

  {
    path: '/temporarypark',
    component: Layout,
    redirect: '/temporarypark/table',
    name: '临时停车管理',
    meta: { title: '临时停车管理', icon: 'link' },
    children: [
      {
        path: 'table',
        name: '临时停车列表',
        component: () => import('@/views/pro/temPark/list'),
        meta: { title: '停车列表' }
      },
      {
        path: 'save',
        name: '添加临时停车',
        component: () => import('@/views/pro/temPark/save'),
        meta: { title: '添加临时停车'}
      },
      {
        path: 'update/:id',
        name: 'ProTemParkEdit',
        component: () => import('@/views/pro/temPark/save'),
        meta: { title: '修改临时停车', noCache: true },
        hidden: true
      }
    ]
  },


  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
